package com.lfd.service.impl;

import java.util.List;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lfd.vo.OptionVo;
import com.lfd.vo.ProductVo;
import com.lfd.mapper.IProductMapper;
import com.lfd.service.ProductService;
import com.lfd.entity.Product;

@Service
public class IProductServiceimpl implements ProductService {
	@Autowired
	private IProductMapper IproductMapper;

	/**
	 * 查询总数
	 */
	@Override
	public int CountAll() {
		return IproductMapper.CountAll();
	}

	/**
	 * 查询
	 */
	@Override
	public List<ProductVo> queryList(Product product, Integer page, Integer limit) {
		List<ProductVo> selectList = IproductMapper.selectList(product, (page - 1) * limit, limit);

		return selectList;
	}

	/**
	 * 添加
	 */
	@Override
	public void addOne(Product product) {
		IproductMapper.inserts(product);
	}

	/**
	 * 下拉框
	 */
	@Override
	public List<OptionVo> selectOptions() {
		List<OptionVo> selectOptions = IproductMapper.selectOptions();
		return selectOptions;
	}

	/**
	 * 根据id渲染数据
	 */
	@Override
	public ProductVo selectVo(Long pid) {
		return IproductMapper.selectVo(pid);
	}

	/**
	 * 根据id进行修改
	 */
	@Override
	public void updateByid(Product product) {
		product.setIsDelete(false);
		IproductMapper.updateByid(product);
	}

	/**
	 * 根具id进行单行删除
	 */
	@Override
	public void deleteById(Long id) {
		IproductMapper.deleteById(id);
	}

	/**
	 * 根据ids进行批量删除
	 */
	@Override
	public void batchDel(List<Long> ids) {
		IproductMapper.delAll(ids);
	}
	
	/**
	 * 批量下架
	 */
	@Override
	public void batchDown(List<Integer> ids) {
		// TODO Auto-generated method stub
		IproductMapper.batchDown(ids);
	}

	/**
	 * 批量上架
	 */
	@Override
	public void batchOn(List<Integer> ids) {
		
		IproductMapper.batchOn(ids);
	}

	
	/**
	 *  推荐商品
	 */
	@Override
	public List<ProductVo> Ptj() {
		List<ProductVo> Ptj = IproductMapper.Ptj();
		return Ptj;
	}

	
	/**
	 *   热销商品
	 */
	@Override
	public List<ProductVo> rx() {
		List<ProductVo> rx = IproductMapper.rx();
		return rx;
	}

	
	/**
	 *  轮播图
	 */
	@Override
	public List<ProductVo> lpt() {
		List<ProductVo> lpt = IproductMapper.lpt();
		return lpt;
	}

	
	
	
}
